home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 408_01 / defs.h < prev    next >
C/C++ Source or Header  |  1993-08-22  |  7KB  |  200 lines

  1. /*
  2.     SNEWS 1.91
  3.  
  4.     DEFS.H - General public decls
  5.  
  6.  
  7.     Copyright (C) 1991  John McCombs, Christchurch, NEW ZEALAND
  8.                         john@ahuriri.gen.nz
  9.                         PO Box 2708, Christchurch, NEW ZEALAND
  10.  
  11.     Modifications copyright (C) 1993  Daniel Fandrich
  12.                         <dan@fch.wimsey.bc.ca> or CompuServe 72365,306
  13.  
  14.     This program is free software; you can redistribute it and/or modify
  15.     it under the terms of the GNU General Public License, version 1, as
  16.     published by the Free Software Foundation.
  17.  
  18.     This program is distributed in the hope that it will be useful,
  19.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.     GNU General Public License for more details.
  22.  
  23.     See the file COPYING, which contains a copy of the GNU General
  24.     Public License.
  25.  
  26.  
  27.     Source is formatted with a tab size of 4.
  28.  
  29.  */
  30.  
  31. #include <alloc.h>
  32. #include <time.h>
  33. #include <string.h>
  34. #include <conio.h>
  35. #include <dos.h>
  36. #include <share.h>
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. #include <sys/stat.h>
  41. #include <dir.h>
  42. #include <signal.h>
  43.  
  44. #ifdef __OS2__
  45. #define INCL_DOSNLS
  46. #define INCL_DOSPROCESS
  47. #include <os2.h>
  48. #endif
  49.  
  50.  
  51. #if __TURBOC__ && (__TURBOC__ < 0x300)
  52. #define flockopen fopen        /* old Turbo C compilers didn't support _fsopen */
  53. #elif __TURBOC__ >= 0x300
  54. #define flockopen(a,b) _fsopen(a,b,SH_DENYWR)
  55. #endif
  56. /* MSC supports flockopen(), & hopefully the same way as I'm defining it!
  57.    This isn't a very good way of doing things -- change the flockopen calls to
  58.    use _fsopen directly */
  59.  
  60.  
  61. #define VERSION      "Simple NEWS 1.91"
  62.  
  63. #define HIST_MEM_LIMIT  75000l  /* leave this much RAM free after loading history */
  64.  
  65. #define ACTIVE_NUM_LEN   8      /* length of the numbers in the active file */
  66.  
  67. #define TRUE     1
  68. #define FALSE    0
  69.  
  70. #define IOBUFSIZE    8192
  71.  
  72. /* this is the data we get from the UUPC .rc files */
  73.  
  74. typedef struct {
  75.     char temp_name[80];           /* unbatch temp file             */
  76.     char temp_str[80];              /* Temporary dir display str     */
  77.     char news_dir[80];            /* news base directory           */
  78.     char incoming_dir[80];        /* incoming news spool directory */
  79.     char user[80];                /* current user id               */
  80.     char my_name[80];             /* my full name                  */
  81.     char my_domain[80];           /* our domain                    */
  82.     char my_site[80];             /* site name                     */
  83.     char my_organisation[80];     /* organisation                  */
  84.     char replyuser[80];           /* Reply-To User address         */
  85.     char replydomain[80];         /* Reply-To User domain          */
  86.     char mail_server[80];         /* where posts are routed to     */
  87.     char editor[80];              /* system editor                 */
  88.     char home[80];                /* home mail directory           */
  89.     char signature[80];           /* signature file                */
  90.     char alias_file[80];          /* alias file                    */
  91.     char extract_file[80];        /* article extract file          */
  92.     char uncompress[80];          /* batch uncompress program      */
  93.     char hotpipe[80];             /* hotkey (F4) pipe program      */
  94. } INFO;
  95.  
  96.  
  97. /* NOTE - if hi_num and lo_num are the same there are no articles */
  98.  
  99. typedef struct active {
  100.     char   group[60];           /* group name                               */
  101.     char   gp_file[9];          /* name of the file that the data is in     */
  102.     char   post;                /* y=allowed to post, n=not, m=moderated    */
  103.     char   local;               /* 1=local news group                       */
  104.     long   lo_num;              /* lowest number less one                   */
  105.     long   hi_num;              /* highest number                           */
  106.     long   num_pos;             /* file offset of the numbers               */
  107.     struct active *next;        /* next entry                               */
  108.     struct active *last;        /* last entry                               */
  109.     int    index;               /* which number in the list, from 0         */
  110.     char   *read_list;          /* array hi_num-lo_num long. TRUE=read it   */
  111. } ACTIVE;
  112.  
  113.  
  114. /*
  115.  *  READ LIST:
  116.  *      The list of articles which has been seen by a user is kept in an
  117.  *      ascii file, which has a newsgroup name followed by the list
  118.  *      of article numbers which have been seen.
  119.  *
  120.  *      The file is read by 'load_read_list', which allocates and array of
  121.  *      flags, one per article, and plugs these into the ACTIVE structure.
  122.  *      The flags are set to TRUE when a user has seen an article.
  123.  *
  124.  *      On shutdown a new 'snews.nrc' file is written
  125.  */
  126.  
  127. /*
  128.  *  This structure is an index to the history file.  'mid' is a 32bit hash
  129.  *  of the message id.  'offset' is the offset into the history file, and
  130.  *  'next' makes the linked list
  131.  */
  132.  
  133. typedef struct hist_list {
  134.     long mid;
  135.     long offset;
  136.     struct hist_list *next;
  137. } HIST_LIST;
  138.  
  139.  
  140. /*
  141.  *  This linked list is returned by 'look_up_history'.  It is a list
  142.  *  of the groups to which an article has been crossposted.  It does
  143.  *  not include self
  144.  */
  145.  
  146. typedef struct cross_posts {
  147.     char   group[60];            /* group name                               */
  148.     long   art_num;              /* article number in this group             */
  149.     struct cross_posts *next;    /* next entry                               */
  150. } CROSS_POSTS;
  151.  
  152. extern char *char_set_names[];
  153. extern INFO my_stuff;
  154. extern int active_code_page;
  155. extern enum char_sets current_char_set;
  156. extern volatile int break_hit;
  157.  
  158. #ifndef ACTIVE_C
  159.  
  160. extern int textb, textf, headb, headf, helpf, helpb, msgf, msgb;
  161.  
  162. #endif
  163.  
  164.  
  165. ACTIVE *load_active_file(void);
  166. void close_active_file(void);
  167. void close_active(void);
  168. ACTIVE *find_news_group(char *group);
  169. void update_active_entry(ACTIVE *a);
  170. char *make_news_group_name(char *ng);
  171.  
  172. void save_read_list(void);
  173. void load_read_list(void);
  174.  
  175. int load_stuff(void);
  176.  
  177. void cdecl sig_break();
  178.  
  179. char *expand_filename(char *filename);
  180.  
  181. FILE *open_out_file(char *ng);
  182. FILE *open_index_file(char *ng);
  183.  
  184. int post_sequence(void);
  185.  
  186. void *xmalloc(size_t size);
  187.  
  188. int check_valid_post_group(char *ng);
  189. int is_local_group(char *ng);
  190.  
  191. FILE *open_hist_file(void);
  192. void close_hist_file(void);
  193. void add_hist_record(char *msg_id, char *ng);
  194.  
  195. HIST_LIST *load_history_list(void);
  196. void free_hist_list(void);
  197. HIST_LIST *find_msg_id(char *msg_id);
  198. CROSS_POSTS *look_up_history(char *msg_id, char *ng);
  199. void free_cross_post_list(CROSS_POSTS *cx);
  200.